package dao.hibernateImpl.basic;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import action.BltAction;

import model.basic.BASICCATEGORY;
import dao.CategoryDAO;
import dao.helper.HibernateConfigurationHelper;
import dao.hibernateImpl.BaseHibernateImpl;
import dao.hibernateImpl.IndexHibernateImpl;
import dao.index.IndexDAO;

public class CategoryHibernateImpl extends IndexHibernateImpl implements IndexDAO, CategoryDAO {


	public List findTop7CategoryList(BASICCATEGORY bc){
		
		findCate(bc);
//		System.out.println(this.sql);
		return this.findList(0, 7);
	}
	public List findTop4CategoryList(BASICCATEGORY bc){
		

//		System.out.println(this.sql);
		findCate(bc);
		return this.findList(0, 4);
	}
	public void findCate(BASICCATEGORY bc){
		StringBuffer sb=new StringBuffer();
		sb=sb.append(this.select);
		sb.append(this._space);
		sb.append(bc.get_ID());
		sb.append(this._comma);
		sb.append(bc.get_CATEGORYNAME());
		sb.append(this._space);
		sb.append(this.from);
		sb.append(this._space);
		HibernateConfigurationHelper hh=new HibernateConfigurationHelper();
		sb.append(hh.getTableName(bc.getClass()));
		
		this.setSql(sb.toString());
	}
	public static void main(String[] args) {
		ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
		
		CategoryDAO ch=(CategoryDAO)ac.getBean("CategoryDAO");
		BASICCATEGORY bc=new model.video.category.VIDEOCATEGORY();
		ch.findTop7CategoryList(bc);
	}
		
}
